import Ember from 'ember';
import BaseBusiness from '../base-business';
import Pagination from '../pagination';

export default BaseBusiness.extend(Pagination,{
  header_title:'活动项目列表',

  model:function(){
    return {};
  },
  buildQueryParams:function(){
    var params=this.pagiParamsSet();
    var curController = this.getCurrentController();
    var filter={};
    var sort;
    if (curController) {
        if (curController.get('queryCondition')) {
          filter = $.extend({}, filter, {'name@$like':curController.get('queryCondition')});
        }
    }
    if(this.get('fitpeopleID')){
      filter = $.extend({}, filter, {'[fitpeople][id]':this.get('fitpeopleID')});
    }
    // if(this.get('countTypeID')){
    //   filter = $.extend({}, filter, {'[countType][id]':this.get('countTypeID')});
    // }
    // if(this.get('valueTypeID')){
    //   filter = $.extend({}, filter, {'[serviceValueType][id]':this.get('valueTypeID')});
    // }
    params.filter = filter;
    return params;
  },
  doQuery:function(){
    var params=this.buildQueryParams();
    var serviceList=this.findPaged('customeractivityserviceitem',params,function(serviceList){});
    this.getCurrentController().set("serviceList", serviceList);
    this.getCurrentController().set("periodID",'');
  },
  actions:{
    search:function(){
      this.doQuery();
    },
    serviceTypeSelect(fitpeople){
      if(fitpeople){
        this.set('fitpeopleID',fitpeople.get('id'));
      }else{
        this.set('fitpeopleID','');
      }

      this.doQuery();
    },
    // countTypeSelect(countType){
    //   if(countType){
    //     this.set('countTypeID',countType.get('id'));
    //   }else{
    //     this.set('countTypeID','');
    //   }

    //   this.doQuery();
    // },
    // serviceValueTypeSelect(valueType){
    //   if(valueType){
    //     this.set('valueTypeID',valueType.get('id'));
    //   }else{
    //     this.set('valueTypeID','');
    //   }
    //   this.doQuery();
    // }
  },
  setupController: function(controller,model){
    this.doQuery();
    this._super(controller,model);


  }
});
